Adds a toKebabCase() method to the String prototype #56
Adds a toKebabCase() method to the String prototype #56thibaultzanini wants to merge 2 commits intomainfrom
toKebabCase() method to the String prototype #56Conversation
toKebabCase() method to the String prototype
marchant
left a comment
There was a problem hiding this comment.
We already have logic for that we should use
| * @example | ||
| * "Hello World".toKebabCase(); // "hello-world" | ||
| */ | ||
| Object.defineProperty(String.prototype, "toKebabCase", { |
There was a problem hiding this comment.
We have a KebabCaseConverter that uses an external dependency ( https://www.npmjs.com/package/just-kebab-case ) that is now at 4.2.0 vs
"just-kebab-case": "^4.0.1",
in mod's package.json.
The code us here:
https://github.com/angus-c/just/blob/master/packages/string-kebab-case/index.cjs
which seems a bit more complete than what you have here. I've known of Angus Croll the author for a while, it might take sense to keep those kind of low level dependencies.
In term of pattern, the method from this package is effectively a converter in mod's terms. So it would make sense to limit the dependencies for String to use Mod's KebabCaseConverter as the core logic, and if for some reason we decide to inline the code and remove the dependency, the the String's toKebabCase() method wouldn't need to change
Adds a
toKebabCase()method to the String prototype for converting strings to kebab-case format.Usage: